﻿#if WINDOWS
using FunArts.EasyDevOps.Platforms.Windows.Service.Impl;
#endif
using FunArts.EasyDevOps.Rcl;
using FunArts.EasyDevOps.Rcl.Repertories;
using FunArts.EasyDevOps.Rcl.Repertories.Impl;
using FunArts.EasyDevOps.Rcl.Service;
using FunArts.EasyDevOps.Rcl.Service.Impl;
using Microsoft.Extensions.Logging;
using Microsoft.Maui.Controls.PlatformConfiguration;

namespace FunArts.EasyDevOps
{
    public static class MauiProgram
    {
        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();
            builder
              .UseMauiApp<App>()
              .ConfigureFonts(fonts =>
              {
                  fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
              });

            builder.Services.AddMauiBlazorWebView();
            builder.Services.AddMasaBlazor();

#if DEBUG
    		builder.Services.AddBlazorWebViewDeveloperTools();
    		builder.Logging.AddDebug();
#endif

            #region 单例
#if WINDOWS

            #region 仓储
            builder.Services.AddSingleton<INginxConfigRepertory, NginxConfigRepertory>();
            builder.Services.AddSingleton<IKeepalivedConfigRepository, KeepalivedConfigRepository>();
            #endregion

            #region 服务
            builder.Services.AddSingleton<ISshClientService, SshClientService>();
            builder.Services.AddSingleton<ILocalFileService, FunArts.EasyDevOps.Platforms.Windows.Service.Impl.LocalFileService>();
            builder.Services.AddSingleton<IRemoteNginxService, RemoteNginxService>();
            builder.Services.AddSingleton<IRemoteKeepAlivedService, RemoteKeepAlivedService>();
            #endregion

#endif

            #endregion

            return builder.Build();
        }
    }
}
